<?php


use think\Request;

/**
 * 状态
 * @param $status
 * @return string
 */
function status($status, $id)
{
    $controller = Request::instance()->controller();
    switch ($status) {
        case 0:
            $result = "<a href=\"javascript:;\"  onclick=\"tijiao('" . url($controller . '/resume') . "',{$id})\"  class='label label-success radius'  title=\"点击恢复\">恢复</a>";
            break;
        case 1:
            $result = "<a href=\"javascript:;\"  onclick=\"tijiao('" . url($controller . '/forbid') . "',{$id})\"  class='label label-danger radius' title=\"点击禁用\">禁用</a>";
            break;
        default:
            $result = "";
            break;
    }
    return $result;
}


/**
 * 状态
 * @param $status
 * @return string
 */
function check($status)
{
    switch ($status) {
        case 0:
            $result = '<a class=\'label label-danger radius\' >未阅</a>';
            break;
        case 1:
            $result = '<a class=\'label label-success radius\' >已阅</a>';
            break;
        default:
            $result = "";
            break;
    }
    return $result;
}

/**
 * 推荐
 * @param $status
 * @return string
 */
function tuijian($status, $id)
{
    $controller = Request::instance()->controller();
    switch ($status) {
        case 0:
            $result = "<a href=\"javascript:;\"  onclick=\"tijiao('" . url($controller . '/Rrecommended') . "',{$id})\"  class='label label-success radius'  title=\"点击推荐\">推荐</a>";
            break;
        case 1:
            $result = "<a href=\"javascript:;\"  onclick=\"tijiao('" . url($controller . '/NotRrecommended') . "',{$id})\"  class='label label-danger radius' title=\"点击不推荐\">不推荐</a>";
            break;
        default:
            $result = "";
            break;
    }
    return $result;
}


/**
 * 排序
 * @param $status
 * @return string
 */
function sortby($status, $id)
{
    $controller = Request::instance()->controller();
    $result = " <input name=\"sort\" class=\"input-text\" value=\"{$status}\" onblur=\"change('" . url($controller . '/sort') . "',this,{$id})\"  type=\"number\"/>";
    return $result;
}

function delDir($dirpath){
    $dh=opendir($dirpath);
    while (($file=readdir($dh))!==false) {
        if($file!="." && $file!="..") {
            $fullpath=$dirpath."/".$file;
            if(!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                delDir($fullpath);
                @rmdir($fullpath);
            }
        }
    }
    closedir($dh);
}